#!/bin/sh
# ======================================================================
# sch2ps - Convert gschem schematic to Postscript
#
# Copyright (C) 2006 Dick Streefland
#
# This is free software, licensed under the terms of the GNU General
# Public License as published by the Free Software Foundation.
# ======================================================================

tmp=/tmp/tmp$$.scm
trap "rm -f $tmp gschem.log" 0 1 2 3 15

cat <<EOF > $tmp
; Script to generate a Postscript file.
; Usage: gschem -q -s <script> -o <file>.ps <file>.sch
(output-orientation "portrait")
(output-type "limits")
(output-text "ps")
(gschem-use-rc-values)
(gschem-print "/dev/null")
(gschem-exit)
EOF

for	i
do
	case	"$i" in
	*.sch)
		ps="${i%.sch}.ps"
		gschem -q -s $tmp -o "$ps" "$i"
		;;
	*)
		echo "Error: $i is not a schematic file (*.sch)"
		exit 1
	esac
done
